<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0055)http://www.jq22.com/demo/shangchengxiangmu201701221233/ -->
<html style=""
      class=" js canvas canvastext no-touch rgba backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations cssgradients csstransforms csstransforms3d csstransitions fontface">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>商品详情</title>
    <link rel="stylesheet" href="/js/productExpend/shouye.css">
    <script src="/js/common.js"></script>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <script src="js/productExpend/jquery-1.10.2.js"></script>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/productExpend/modernizr-custom-v2.7.1.min.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>

    <script>
        $(document).ready(function () {
            var $miaobian = $('.Xcontent08>div');
            var $huantu = $('.Xcontent06>img');
            var $miaobian1 = $('.Xcontent26>div');
            $miaobian.mousemove(function () {
                miaobian(this);
            });
            $miaobian1.click(function () {
                miaobian1(this);
            });

            function miaobian(thisMb) {
                for (var i = 0; i < $miaobian.length; i++) {
                    $miaobian[i].style.borderColor = '#dedede';
                }
                thisMb.style.borderColor = '#cd2426';

                $huantu[0].src = thisMb.children[0].src;
            }

            function miaobian1(thisMb1) {
                for (var i = 0; i < $miaobian1.length; i++) {
                    $miaobian1[i].style.borderColor = '#dedede';
                }
//		thisMb.style.borderColor = '#cd2426';
                $miaobian.css('border-color', '#dedede');
                thisMb1.style.borderColor = '#cd2426';
                $huantu[0].src = thisMb1.children[0].src;
            }

            $(".Xcontent33").click(function () {
                var value = parseInt($('.input').val()) + 1;
                $('.input').val(value);
            })

            $(".Xcontent32").click(function () {
                var num = $(".input").val()
                if (num > 0) {
                    $(".input").val(num - 1);
                }

            })

        })
    </script>

    <script>
        $(function () {
            var productId = getParams().productId;
            var userId = getParams().userId;
            $.get('/products/' + productId, function (data) {
                $('#name').html(data.name);
                $('#creditCost').html(data.price);
                $('#coverUrl').attr('src', data.coverUrl)

                //立即购买
                $('#buy').click(function () {
                    var count = $('.input').val();
                    var price = data.price;
                    price = price * count;

                    $.get('/users/' + userId + '/credits', function (data) {
                         if (data.credit < price) {
                             alert("温馨提示:积分不足");
                         }
                         else {
                             var dateNow = new Date();
                             createDate = dateTransfer(dateNow,'yyyy-MM-dd HH:mm:ss');
                             var order = new Date().toLocaleDateString() + '-' + Math.random() * 100000 + userId;
                             order = order.split('.')[0];
                             console.log(order);
                             $.get('/users/addOrder', {userId:userId,productId:productId,count:count,orderNum:order, createTime:createDate});
                             $.get('/products/' + productId + '/changeCount',{count:count});
                             $.get('/users/spendCredits', {id:userId, credit:price}, function (data) {
                                 alert("温馨提示:兑换成功")
                             });
                         }
                     })
                })

                $('.Xcontent35').click(function () {
                    $.get('/users/addProducts', {userId: userId, productId: productId});
                    window.location.href = '/shoppingCart.html?productId=' + productId + '&userId=' + userId;
                })
            })
        })
    </script>
</head>
<body style="">
<div class="Xcontent">
    <ul class="Xcontent01">
        <div class="Xcontent06"><img src="" id="coverUrl"></div>
        <ol class="Xcontent08">
        </ol>
        <ol class="Xcontent13">
            <div class="Xcontent14"><a href="http://www.jq22.com/demo/shangchengxiangmu201701221233/#"><p id="name">
                物品名称</p></a></div>
            <div class="Xcontent17">
                <p class="Xcontent18">消耗积分</p>
                <p class="Xcontent19"><span id="creditCost"></span></p>
                <div class="Xcontent20">
                    <p class="Xcontent21">促销</p>
                    <img src="/js/productExpend/X12.png">
                    <p class="Xcontent22">领610元新年礼券，满再赠好礼</p>
                </div>
                <div class="Xcontent23">
                    <p class="Xcontent24">服务</p>
                    <p class="Xcontent25">30天无忧退货&nbsp;&nbsp;&nbsp;&nbsp; 48小时快速退款 &nbsp;&nbsp;&nbsp;&nbsp; 满88元免邮</p>
                </div>
            </div>
            <div class="Xcontent30">
                <p class="Xcontent31">数量</p>
                <div class="Xcontent32"><img src="/js/productExpend/X15.png"></div>
                <form>
                    <input class="input" value="1"></form>
                <div class="Xcontent33"><img src="/js/productExpend/16.png"></div>
            </div>
            <div class="Xcontent34"><a href="javascript:;" id="buy"><img src="/js/productExpend/X17.png"></a></div>
            <div class="Xcontent35"><a href="javascript:;"><img src="/js/productExpend/X18.png"></a></div>
        </ol>
    </ul>
</div>


</body>
</html>